<?php
	switch($action){
		case 'manage':
			if(!$_userid) showmessage('您还没有登陆，即将跳转到登陆页面',url("?module=member&action=login&forward=".urlencode(URL)));
			// common
			if(!isset($action)) $action = 'manage';
			$companytpl_config = include WWW_ROOT.'themes/'.TPL_NAME.'/yellowpage/companytplnames.php';
			foreach($companytpl_config AS $_k=>$_v)
			{
				$_array_group = explode(',',$_v['groupid']);
				if(!in_array($_groupid,$_array_group)) unset($companytpl_config[$_k]);
			}
			// common
	
			$diy = $company_user_infos['diy'];
			$tplname = $company_user_infos['tplname'];
	
			include template('template_manage.html', 'yellowpage');
		break;
	
		case 'preview':
			if(!$_userid) showmessage('您还没有登陆，即将跳转到登陆页面',url("?module=member&action=login&forward=".urlencode(URL)));
			// common
			if(!isset($action)) $action = 'manage';
			$companytpl_config = include WWW_ROOT.'themes/'.TPL_NAME.'/yellowpage/companytplnames.php';
			foreach($companytpl_config AS $_k=>$_v)
			{
				$_array_group = explode(',',$_v['groupid']);
				if(!in_array($_groupid,$_array_group)) unset($companytpl_config[$_k]);
			}
			// common
			
			//extract($company_user_infos);
			
			// ....
			//$position = "<a href='$siteurl'>$system_name[index]</a> > $system_name[$category]";
			if($map)
			{
				$maps = explode('|',$map);
				$x = $maps[0];
				$y = $maps[1];
				$z = $maps[2];
			}
			$keys = array_keys($companytpl_config);
			if(!in_array($style,$keys)) showmessage("风格不存在！");
			define('TPL', $companytpl_config[$style]['tplname']);
			define('WEB_SKIN', 'themes/'.TPL_NAME.'/yellowpage/css/');
			define('SKIN_DIY', WEB_SKIN.$companytpl_config[$style]['style']);
			$banner = $banner ? $banner : 'yp/images/banner.jpg';
			include template( 'com_'.TPL.'-index.html', 'yellowpage');
			break;
	
		case 'template_use':
			if(!$_userid) showmessage('您还没有登陆，即将跳转到登陆页面',url("?module=member&action=login&forward=".urlencode(URL)));
			// common
			if(!isset($action)) $action = 'manage';
			$companytpl_config = include WWW_ROOT.'themes/'.TPL_NAME.'/yellowpage/companytplnames.php';
			foreach($companytpl_config AS $_k=>$_v)
			{
				$_array_group = explode(',',$_v['groupid']);
				if(!in_array($_groupid,$_array_group)) unset($companytpl_config[$_k]);
			}
			// common
			
			$keys = array_keys($companytpl_config);
			if(!in_array($style,$keys)) showmessage("风格不存在！");
			$db->query("UPDATE `".DB_PRE."member_company` SET `tplname`='$style',`diy`=0 WHERE `userid`='$_userid'");
			showmessage('成功启用“'.$companytpl_config[$style]['filename'].'”',$forward);
			break;
	}
?>